home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigantic Games 2
/
Gigantic Games 2.iso
/
pc
/
_b_
/
blackjack
/
bj_trainer.amos
/
bj_trainer.amosSourceCode
< prev
Wrap
AMOS Source Code
|
1994-12-23
|
53KB
|
2,030 lines
'=======================================
' BLACKJACK TRAINER +
' by Peter Cartwright +
' With much thanks to Kevin Hall & +
' others on CIX for suggestions +
' and help. +
' Also much thanks to Aaron Fothergill +
' for pointing out the Randomiser bug +
' which was causing the compiled +
' version to crash. +
'++++++++++++++++++++++++++++++++++++++++
Set Buffer 13
Screen Open 0,320,256,8,Lowres
Screen Close 0
Dim TLX(3),TLY(3),BRX(3),BRY(3)
Dim HARD_DBL(3,10),SOFT_DBL(8,10),HARD_HIT(6,10),SOFT_HIT(4,10),SPLIT(10,10)
Dim CARD_PACK(208),NUM_OF_ACES(3),SOFT(3),PL4YER_COUNT(2)
Dim PL4YERX(2),BUST(2),STAKE(2),DUBBLED(2),LINE$(3),BUTTON$(5),SPEED_ARR$(3)
Global STAKE(),HAND,BLUE_CHIPS,RED_CHIPS,B0B,BANK,PL4YER_COUNT(),DEALER_COUNT
Global NUM_OF_ACES(),SOFT(),POS,HAND,OWES_50P
Global BANK,_OLD_BANK
Global _HI,_LO
Global _WINS,_LOSSES,_DRAWS,_BLACKJACKS,_SPLITS,_DOUBLES,HANDS
Erase 3
BOTTOM_CARD=197-(Rnd(8))
T0P_CARD=0 : SPEED=7 : Set Talk 0,0,110,
_LOAD_ARRAY : Rem Load speed array
' Set starting positions for cards
PL4YERX(1)=208 : PL4YERX(2)=110 : PL4YERY=36 : DEALERX=132 : DEALERY=0 : RESTART=True
Load "trainer:gameover5.abk",3
Load "Trainer:dj_noises1.abk",5
Load "Trainer:blackjack.abk"
Randomize Timer
_SET_UP_1ST_SCREENS
FRONT_END:
Screen 1
Get Sprite Palette
Screen To Front 1
Wait Vbl
RESTART=False
T0P_CARD=0
Clear Key
Auto View Off
Wait 28
Menu$(1)="Details "
Menu$(2)="Options "
Menu$(3)="Info. "
'Details
Menu$(1,1)="Credits "
'options
Menu$(2,1)="Play with Help "
Menu$(2,2)="Play without Help "
Menu$(2,3)="Set Speed "
Menu$(2,4)="Edit Strategy "
Menu$(2,5)="Save Strategy File "
Menu$(2,6)="Load Strategy File "
Menu$(2,7)="Test Current Strategy"
Menu$(2,8)="Quit "
'Rules
Menu$(3,1)="How to Play. "
Menu$(3,2)="House Rules. "
Menu$(3,3)="About Strategy. "
Menu$(3,4)="About Staking. " : X=Free
Menu On
Do
'Screen Copy 1,8,0,16,8 To 1,0,0
If Choice
FL=0
If Choice(1)=1 and Choice(2)=1
_PROCESS["details"]
End If
If Choice(1)=2
If Choice(2)=1
HELPME=True
FL=1
Menu Off
End If
If Choice(2)=2
HELPME=False
FL=1
Menu Off
End If
If Choice(2)=3
SPEED$=SPEED_ARR$((SPEED-4)/3-1)
LINE$(0)="Select a Speed"
LINE$(1)="Current Speed "+SPEED$
BUTTON$(0)="Fast"
BUTTON$(1)="Med."
BUTTON$(2)="Slow"
Menu Off
ALERT[22,8,1,2,3,2]
SPEED=Q*3+4
Menu On
End If
If Choice(2)=4
Menu Off
_EDIT_STRATEGY
Screen Close 2 : Screen 1
Menu On
End If
If Choice(2)=5
_SAVE_STRAT
End If
If Choice(2)=6
_LOAD_STRAT
End If
If Choice(2)=7 : Paper 14 : Pen 15
Curs Off
Locate 10,15 : Print "Loading Files"
Locate 11,16 : Print "Please Wait"
Screen Copy 1,8,0,16,8 To 1,0,0
Menu Off
Screen Close 0 : Erase 1 : Menu Del
Gosub TESTER
Erase 1 : Load "trainer:blackjack.abk"
_SET_UP_1ST_SCREENS
Screen Close 3
Exit
End If
If Choice(2)=8
Erase 1 : Erase 3 : Erase 5
End
End If
If FL=1
Gosub MAIN_BJ_LOOP
End If
End If
If Choice(1)=3
If Choice(2)=1
_PROCESS["_instruct"]
X=Free
End If
If Choice(2)=2
_PROCESS["rules"]
X=Free
End If
If Choice(2)=3
_PROCESS["strategy"]
X=Free
End If
If Choice(2)=4
_PROCESS["staking"]
X=Free
End If
End If
End If
Loop
Goto FRONT_END
MAIN_BJ_LOOP:
Auto View On
_SCROLL_UP
Screen To Front 0
Screen Display 0,128,42,,
Screen 0 : Get Sprite Palette : Screen Show 0
Autoback 1
SET_MAIN_ZONES
AN$="A 6,(64,8)(65,8)" : Ink 2,3
MAKE_PACK
Gosub SHUFFLE
BANK=200
' ST4RT is the main loop. We come here for each brand new hand
ST4RT:
_UPDATE_BANK
SPLIT=False : HAND_FINISHED=False : SPLIT_POSSIBLE=False : POS=0 : HAND=1 : B0B=1
For I=1 To 2 : BUST(I)=False : DUBBLED(I)=False : Next I
For I=1 To 3 : NUM_OF_ACES(I)=0 : SOFT(I)=False : Next I
_TWO_ACES=False
Gosub PLACE_BET
' PLACE_BET uses bobs 1 and 2 for original bet
' bobs 3 and 4 are used split
' bobs 5 to 8 are used for doubles
If RESTART=True : Rem MENU has been pressed on play screen
Sprite Off 1
_SCROLL_DOWN
'Screen To Front 1
Screen 1
'Get Sprite Palette
Menu On
Return
End If
STAKE(HAND)=BET
B0B=8 : Rem B0B is now 8 and DEAL_CARD adds 1 more to start at 9.
' Deal 2 cards to player and 1 to dealer
PL0FFSETX=PL4YERX(HAND) : PL0FFSETY=PL4YERY
Gosub DEAL_CARD : TEST1=RANK : ADJUST_HAND[HAND]
Wait SPEED
PL4YER_COUNT(HAND)=RANK
PL0FFSETX=DEALERX : PL0FFSETY=DEALERY
Gosub DEAL_CARD : Inc POS
Wait SPEED
ADJUST_HAND[3]
DEALER_COUNT=RANK
PL0FFSETX=PL4YERX(HAND) : PL0FFSETY=PL4YERY
Gosub DEAL_CARD : Inc POS
TEST2=RANK
ADJUST_HAND[HAND]
If TEST1=TEST2
SPLIT_POSSIBLE=True
End If
PL4YER_COUNT(HAND)=PL4YER_COUNT(HAND)+RANK
If PL4YER_COUNT(HAND)=22
_TWO_ACES=True
Dec NUM_OF_ACES(HAND)
PL4YER_COUNT(HAND)=PL4YER_COUNT(HAND)-10
End If
If PL4YER_COUNT(HAND)=21
S$="Blackjack"
_NOTICE[S$]
_CLEAR_BOX
PL4YER_COUNT(HAND)=99
HAND_FINISHED=True
End If
ADVICE_GIVEN=False
' Trap the 21 count on a split hand
While HAND_FINISHED=False
If SPLIT and PL4YER_COUNT(HAND)=21
S$="Twenty One!"
_NOTICE[S$]
_CLEAR_BOX
HAND_FINISHED=True
End If
If HELPME
If Not ADVICE_GIVEN
Gosub HELP
ADVICE_GIVEN=True
End If
End If
Repeat
'trap split 21
If HAND_FINISHED
NEWZONE=0
Exit
End If
NEWZONE=Mouse Zone
If Key State(95)=True Then Gosub HELP
Until Mouse Click and NEWZONE<>0
If NEWZONE=1
HAND_FINISHED=True
End If
If NEWZONE=2
Gosub DEAL_CARD : Inc POS
ADVICE_GIVEN=False
ADJUST_HAND[HAND]
PL4YER_COUNT(HAND)=PL4YER_COUNT(HAND)+RANK
'If bust, check for any fresh aces.
If PL4YER_COUNT(HAND)>21 and NUM_OF_ACES(HAND)>0
Dec NUM_OF_ACES(HAND)
PL4YER_COUNT(HAND)=PL4YER_COUNT(HAND)-10
If NUM_OF_ACES(HAND)=0 : Rem only one unaccounted for ace was present
SOFT(HAND)=False
End If
End If
If PL4YER_COUNT(HAND)>21 and PL4YER_COUNT(HAND)<>99
Wait SPEED
S$="Bust!"
_NOTICE[S$]
_CLEAR_BOX
HAND_FINISHED=True
BUST(HAND)=True
TAKE_MONEY
End If
If PL4YER_COUNT(HAND)=21
S$="Twentyone!"
_NOTICE[S$]
_CLEAR_BOX
Wait SPEED
HAND_FINISHED=True
End If
Wait SPEED : Rem avoid double hit?
End If
If NEWZONE=3 and SPLIT_POSSIBLE=True and SPLIT=False
If BANK<STAKE(HAND)
S$="Not enough cash."
_NOTICE[S$]
_CLEAR_BOX
NEWZONE=0
Else
Gosub _SPLIT_PROC
End If
End If
'''' If the hand is soft (SOFT(hand)*10) will equal -10
If NEWZONE=4 and PL4YER_COUNT(HAND)+(SOFT(HAND)*10)<12 and POS=2
If BANK<STAKE(HAND)
S$="Not enough cash."
_NOTICE[S$]
_CLEAR_BOX
NEWZONE=0
Else
Gosub _D0UBLE_PROC
End If
End If
If SPLIT=True and HAND=1 and HAND_FINISHED=True
HAND_FINISHED=False
Inc HAND
POS=2
PL0FFSETX=PL4YERX(HAND)
Channel 1 To Bob 30
AM$="Move -100,0,35"
Amal 1,AM$ : Amal On
While Chanmv(1)
Wend
Bell
Wait 40
ADVICE_GIVEN=False
End If
Wend
If Not SPLIT
If BUST(1)
If BANK<1
GAME_LOST
BANK=200
RESTART=True
End If
Bob Off : Wait Vbl
Goto ST4RT
End If
End If
' If both hands bust, no need for dealer to deal
If BUST(1) and BUST(2)
Bob Off : Wait Vbl
Goto ST4RT
End If
' If player has blackjack, check to see if dealer can get one
If PL4YER_COUNT(HAND)=99
If DEALER_COUNT<>11 and DEALER_COUNT<>10
PAY_SIX_TO_4
Bob Off : Wait Vbl
Goto ST4RT
End If
End If
POS=1
HAND_DECIDED=False
While DEALER_COUNT<17
PL0FFSETX=DEALERX : PL0FFSETY=DEALERY
Gosub DEAL_CARD : Inc POS
Wait SPEED
ADJUST_HAND[3]
DEALER_COUNT=DEALER_COUNT+RANK
' Check for a dealer blackjack
If DEALER_COUNT=21 and POS=2
HAND_DECIDED=True
S$="Dealer gets Blackjack."
_NOTICE[S$]
_CLEAR_BOX
If PL4YER_COUNT(HAND)=99
BANK=BANK+STAKE(HAND)
CLAIM_STAKE
Bob Off : Wait Vbl
Exit
Else
TAKE_MONEY
End If
Bob Off : Wait Vbl
Exit
End If
If PL4YER_COUNT(HAND)=99 and POS=2
HAND_DECIDED=True
Wait 20
PAY_SIX_TO_4
Bob Off : Wait Vbl : Exit
End If
'If DEALER_COUNT>16 and DEALER_COUNT<22 and NUM_OF_ACES(3)>0 Then Exit
'ADJUST "soft"HAND If BUST
If DEALER_COUNT>21 and NUM_OF_ACES(3)>0
Dec NUM_OF_ACES(3) : Rem Adjustment made so cancel this ace.
DEALER_COUNT=DEALER_COUNT-10
End If
Wend
If HAND_DECIDED=True
If BANK<1
GAME_LOST
BANK=200
RESTART=True
End If
Goto ST4RT
End If
' Who's won?
If Not SPLIT
If DEALER_COUNT>21
S$="Dealer Busts."
_NOTICE[S$]
PAY_EVENS
_CLEAR_BOX
Bob Off : Wait Vbl
Goto ST4RT
End If
If DEALER_COUNT>PL4YER_COUNT(HAND)
S$="Dealer Wins"
_NOTICE[S$]
TAKE_MONEY
_CLEAR_BOX
Wait 30
If BANK<1
GAME_LOST
BANK=200
RESTART=True
End If
Bob Off : Wait Vbl
Goto ST4RT
End If
If DEALER_COUNT=PL4YER_COUNT(HAND)
S$="Stand Off."
_NOTICE[S$]
_CLEAR_BOX
BANK=BANK+STAKE(HAND)
CLAIM_STAKE
Bob Off : Wait Vbl
Goto ST4RT
End If
S$="Player Wins."
_NOTICE[S$]
PAY_EVENS
_CLEAR_BOX
Bob Off : Wait Vbl
Goto ST4RT
Else
If DEALER_COUNT>21
S$="Dealer Busts."
_NOTICE[S$]
_CLEAR_BOX
For HAND=1 To 2
If BUST(HAND)=False
End If
PAY_EVENS
_CLEAR_BOX
Next HAND
Bob Off
Goto ST4RT
End If
For HAND=1 To 2
If DEALER_COUNT>PL4YER_COUNT(HAND) and BUST(HAND)=False
If _VOICE_ON
Say " Dealer wins hand"+Str$(HAND)+"."
Else
S$="Dealer wins Hand "+Str$(HAND)+"."
_NOTICE[S$]
End If
TAKE_MONEY
_CLEAR_BOX
Wait 30
If HAND=2
Bob Off : Wait Vbl
If BANK<1
GAME_LOST
BANK=200
RESTART=True
Exit
End If
End If
End If
If DEALER_COUNT<PL4YER_COUNT(HAND) and BUST(HAND)=False
S$="Player Wins Hand "+Str$(HAND)+"."
_NOTICE[S$]
PAY_EVENS
_CLEAR_BOX
If HAND=2
Bob Off : Wait Vbl
End If
End If
If DEALER_COUNT=PL4YER_COUNT(HAND) and BUST(HAND)=False
S$="Standoff on Hand "+Str$(HAND)+"."
_NOTICE[S$]
_CLEAR_BOX
BANK=BANK+STAKE(HAND)
CLAIM_STAKE
If HAND=2
Bob Off : Wait Vbl
End If
End If
Next HAND
Bob Off : Wait Vbl
Goto ST4RT
End If
SHUFFLE:
If _MODE=0 Then Text 124,88,"SHUFFLING"
For I=208 To 2 Step -1
J=Rnd(I)
CARD_PACK(0)=CARD_PACK(J)
CARD_PACK(J)=CARD_PACK(I)
CARD_PACK(I)=CARD_PACK(0)
Next I
X=Free
If _MODE=0
For I=1 To 3
Text 124,88,"SHUFFLING"
Sam Play 1,2,23800
Wait 50
Text 124,88," "
Wait 40
Next I
X=Free
End If
Return
DEAL_CARD:
If _MODE=0 Then Inc B0B
Inc T0P_CARD
If T0P_CARD=BOTTOM_CARD
If _MODE=0
Bob 42,POS*8+PL0FFSETX,POS*8+PL0FFSETY,62
End If
Gosub SHUFFLE
T0P_CARD=1
BOTTOM_CARD=197-Rnd(8)
If _MODE=0
Bob Off 42
Wait Vbl
End If
End If
SUIT=CARD_PACK(T0P_CARD)/100
RANK=CARD_PACK(T0P_CARD) mod 100
If _MODE=0
Bob B0B,POS*8+PL0FFSETX,POS*8+PL0FFSETY,9+(SUIT*13)+RANK
Sam Play 1,1,23000
Wait 3
End If
X=Free
Return
_SPLIT_PROC:
SPLIT=True
SPLIT_POSSIBLE=False : Rem Only one split allowed
Dec POS : Dec POS
BANK=BANK-STAKE(HAND)
If _MODE=0 Then Text 68,188,"�"+Str$(BANK)
PL4YER_COUNT(1)=RANK
PL4YER_COUNT(2)=RANK
SOFT(HAND+1)=SOFT(HAND)
If NUM_OF_ACES(1)=2 Then Dec NUM_OF_ACES(1)
NUM_OF_ACES(2)=NUM_OF_ACES(1)
STAKE(2)=STAKE(1)
Inc POS
' Move bottom card across
If _MODE=0
Channel 1 To Bob B0B
AM$="Move -106,-8,40"
Amal 1,AM$ : Amal On
While Chanmv(1)
Wend
Wait 20
If BLUE_CHIPS>0
_YOFFSET=186-Y Bob(1)
Else
_YOFFSET=186-Y Bob(2)
End If
AM$="Move 36,0,20"
AM2$="Move -64,-"+Str$(_YOFFSET)+",20"
Channel 1 To Bob 1
Channel 2 To Bob 2
Channel 3 To Bob 3
Channel 4 To Bob 4
'place extra chips
If RED_CHIPS>0
Bob 4,160,186-BLUE_CHIPS*2,I Bob(2)
Amal 2,AM$
Amal 4,AM2$
End If
If BLUE_CHIPS>0
Bob 3,160,186,I Bob(1)
Amal 1,AM$
Amal 3,AM2$
End If
Amal On
While Chanmv(1)
Wend
End If
For I=1 To 2
PL0FFSETX=PL4YERX(I) : PL0FFSETY=PL4YERY
Gosub DEAL_CARD
ADJUST_HAND[I]
PL4YER_COUNT(I)=PL4YER_COUNT(I)+RANK
' check that it's not 2 aces
If PL4YER_COUNT(I)>21
PL4YER_COUNT(I)=PL4YER_COUNT(I)-10
Dec NUM_OF_ACES(I)
End If
Wait 5
Next I
If _MODE=0
Bob 30,225,15,63
Wait Vbl
Bell
Wait 40
End If
Inc POS
PL0FFSETX=PL4YERX(1)
ADVICE_GIVEN=False
Return
_D0UBLE_PROC:
BANK=BANK-STAKE(HAND)
DUBBLED(HAND)=True
If _MODE=0 Then Text 68,188,"�"+Str$(BANK)
STAKE(HAND)=STAKE(HAND)*2
If _MODE=0
Channel 1 To Bob 5
Channel 2 To Bob 6
If HAND=2
HAND=3
Channel 1 To Bob 7
Channel 2 To Bob 8
End If
If BLUE_CHIPS>0
Bob HAND+4,160,186,I Bob(1)
Wait Vbl
AM$="Move "+Str$(X Bob(HAND)-160-20)+","+Str$(Y Bob(HAND)-186)+",20"
Amal 1,AM$
End If
If RED_CHIPS>0
Bob HAND+5,160,186,I Bob(2)
Wait Vbl
AM$="Move "+Str$(X Bob(HAND+1)-160-20)+","+Str$(Y Bob(HAND+1)-186)+",20"
Amal 2,AM$
End If
If HAND=3
HAND=2
End If
Amal On
While Chanmv(1) or Chanmv(2)
Wend
Wait Vbl
Wait 35
End If
Gosub DEAL_CARD
If _MODE=0 Then Wait 20
ADJUST_HAND[HAND]
PL4YER_COUNT(HAND)=PL4YER_COUNT(HAND)+RANK
' If over 21 an ace has been drawn to 11, so reduce by 10
If PL4YER_COUNT(HAND)>21
PL4YER_COUNT(HAND)=PL4YER_COUNT(HAND)-10
End If
HAND_FINISHED=True
Return
HELP:
If POS=2 : Rem Splits and Doubles only on 3rd card
'first look for splits
SPLIT_ADVICE=False
If SPLIT_POSSIBLE and HAND=1
SPLIT_HELP
End If
If SPLIT_ADVICE
Return
End If
' then check for doubles
If PL4YER_COUNT(HAND)+(SOFT(HAND)*10)<12
D0UBLE=False
If PL4YER_COUNT(HAND)+(SOFT(HAND)*10)<9 and SOFT(HAND)
Gosub SOFT_DOUBLE_HELP
End If
If PL4YER_COUNT(HAND)>8 and Not SOFT(HAND)
HARD_D0UBLE_HELP
End If
If D0UBLE
Return
End If
End If
End If
' Then look at soft hands
If SOFT(HAND)
SOFT_HIT_HELP
Else
HARD_HIT_HELP
End If
'
Return
SOFT_DOUBLE_HELP:
' 201 to 270 SOFT_DBL
_OFFSET=199
PL4Y=19-PL4YER_COUNT(HAND) : DEAL=DEALER_COUNT-1
SEL=Peek(Start(8)+_OFFSET+(PL4Y-1)*10+DEAL)
If SEL=1
LIGHT[4]
D0UBLE=True
End If
Return
PLACE_BET:
RESTART=False
BET_PLACED=False
BET=0
_UPDATE_BANK
BUTTONS_CLEAR=True
Repeat : Rem incre/decrement bet until bet is placed
Z=Mouse Zone : K=Mouse Key
Wait 6
If K<>0 and BET=0
If Z=10
RESTART=True : Exit
End If
If Z=9
_SAVE_GAME
End If
If Z=8
_LOAD_GAME
End If
End If
If K<>0
If Z=5
If K=1
If BET<25 and BANK>0
Inc BET
Dec BANK
_UPDATE_BANK
End If
End If
If K=2
If BET>0
Dec BET
Inc BANK
_UPDATE_BANK
End If
End If
End If
If Z=6
If K=1
If BET<21 and BANK>4
BET=BET+5
BANK=BANK-5
_UPDATE_BANK
End If
End If
If K=2
If BET>4
BET=BET-5
BANK=BANK+5
_UPDATE_BANK
End If
End If
End If
End If
MAKE_CHIP_PILE[BET]
M0USE_CHIP_MOVE
Wait Vbl
If K=1 and Z=7 and BET>0
BET_PLACED=True
End If
Until BET_PLACED
If BET mod 5=0 Then Bob Off B0B+1 : Rem loose a loose sprite.
Wait 10 : Rem this stops the mouse press carrying thru to next test.
Return
TESTER:
_MODE=1
Screen Open 0,320,256,8,Lowres
Curs Off : Flash Off
Flash Off : Curs Off
Load "Trainer:tester.pic.pac",11
Unpack 11 To 0 : Erase 11
Screen Hide 0
Load "trainer:tester_spr.abk"
LINE1$="SUMMARY"
LINE2$="======="
LINE3$=" Session Hands Splits Doubles B/Jacks Wins Losses Draws Prof/Loss"
SESS$="Session No."
STAKE$="Staking Plan No."
Auto View Off
Screen Display 0,136,44,,
Screen Open 3,320,256,8,Lowres
Flash Off
Load "Trainer:stake_plans.pac",12
Unpack 12 To 3 : Erase 12
Palette 0,$FFF,$666,$0
Screen Close 1
Do
Screen Hide 0
SESSION=1
Auto View On
Gosub _GET_PLAN
Exit If PLAN=17 : Rem Zone 17 is the MENU button.
_GET_NUM_OF_SESSIONS
_GET_TOP_BOTTOM
_GET_NUM_HANDS
_GRAPH_PAPER
Screen To Back 3
Screen Open 2,640,512,2,Hires
Screen Hide 2 : Curs Off
Palette 2,$FFF,$0
Locate 0,0 : Centre LINE1$
Locate 0,1 : Centre LINE2$
Locate 0,2 : Print LINE3$
Screen Show 0
Screen 0
Hide
While SESSION<NUM_OF_SESSIONS+1
If SESSION>1 Then _GRAPH_PAPER
BOTTOM_CARD=197-(Rnd(8))
T0P_CARD=0
MAKE_PACK
Gosub SHUFFLE
_HI=0 : _LO=0 : BANK=0 : _OLD_BANK=0 : HANDS=0 : _WINS=0 : _LOSSES=0
_BLACKJACKS=0 : _DRAWS=0 : _SPLITS=0 : _DOUBLES=0
X#=0
STAKE(1)=_STARTING_STAKE
_ACC_TOT_STAKES=_ACC_TOT_STAKES+STAKE(1)
Gosub _RUN_TEST
Gosub _PRINT_SUM_LINE
Inc SESSION
Wend
Gosub _PRINT_SUM_TOTALS
Screen To Front 2 : Screen Show 2
While Mouse Key=0
Wend
Screen Hide 0
Screen Close 2
Show
Loop
' PLAN 17 has been chosen in the Do Loop so return.
Return
'
_RUN_TEST:
RESULT$=""
ST4RT2:
Gosub _UPDATE_HI_LO
_GRAPH
If BANK<_LOWEST Then Screen Close 1 : Return
If BANK>_HIGHEST Then Screen Close 1 : Return
Inc HANDS
If HANDS>NUM_OF_HANDS Then HANDS=HANDS-1 : Screen Close 1 : Return
SPLIT=False : HAND_FINISHED=False : SPLIT_POSSIBLE=False : HAND=1 : POS=0
For I=1 To 2 : BUST(I)=False : DUBBLED(I)=False : Next I
For I=1 To 3 : NUM_OF_ACES(I)=0 : SOFT(I)=False : Next I
R$=RESULT$
' Add the name of your user defined Staking Plan subroutine.
On PLAN Gosub _STAKE1,_STAKE2,_STAKE3,_STAKE4,_STAKE5,_STAKE6,_STAKE7,_STAKE8
_ACC_TOT_STAKES=_ACC_TOT_STAKES+STAKE(HAND)
BANK=BANK-STAKE(HAND)
' Deal 2 cards to player and 1 to dealer
Gosub DEAL_CARD
TEST1=RANK
ADJUST_HAND[HAND]
PL4YER_COUNT(HAND)=RANK
Gosub DEAL_CARD
ADJUST_HAND[3]
DEALER_COUNT=RANK
Inc POS
Gosub DEAL_CARD
Inc POS
TEST2=RANK
ADJUST_HAND[HAND]
If TEST1=TEST2
SPLIT_POSSIBLE=True
End If
PL4YER_COUNT(HAND)=PL4YER_COUNT(HAND)+RANK
If PL4YER_COUNT(HAND)=21
PL4YER_COUNT(HAND)=99
HAND_FINISHED=True
End If
While HAND_FINISHED=False
If SPLIT and PL4YER_COUNT(HAND)=21
HAND_FINISHED=True
End If
Gosub HELP
'NEWZONE will be set by HELP
If NEWZONE=1
HAND_FINISHED=True
End If
If NEWZONE=2
Gosub DEAL_CARD
Inc POS
ADJUST_HAND[HAND]
PL4YER_COUNT(HAND)=PL4YER_COUNT(HAND)+RANK
'If bust, check for any fresh aces.
If PL4YER_COUNT(HAND)>21 and NUM_OF_ACES(HAND)>0
Dec NUM_OF_ACES(HAND)
PL4YER_COUNT(HAND)=PL4YER_COUNT(HAND)-10
If NUM_OF_ACES(HAND)=0 : Rem only one unaccounted for ace was present
SOFT(HAND)=False
End If
End If
If PL4YER_COUNT(HAND)>21 and PL4YER_COUNT(HAND)<>99
HAND_FINISHED=True
BUST(HAND)=True
End If
If PL4YER_COUNT(HAND)=21
HAND_FINISHED=True
End If
End If
If NEWZONE=3 and SPLIT_POSSIBLE=True and SPLIT=False
Inc _SPLITS
Gosub _SPLIT_PROC
End If
' If the hand is soft (SOFT(hand)*10) will equal -10
If NEWZONE=4 and PL4YER_COUNT(HAND)+(SOFT(HAND)*10)<12 and POS=2
Inc _DOUBLES
Gosub _D0UBLE_PROC
End If
If SPLIT=True and HAND=1 and HAND_FINISHED=True
HAND_FINISHED=False
Inc HAND
POS=2
ADVICE_GIVEN=False
End If
Wend
If Not SPLIT
If BUST(1)
Goto ST4RT2
End If
End If
' If both hands bust, no need for dealer to deal
If BUST(1) and BUST(2) Then Goto ST4RT2
' If player has blackjack, check to see if dealer can get one
If PL4YER_COUNT(HAND)=99
If DEALER_COUNT<>11 and DEALER_COUNT<>10
BANK=BANK+STAKE(HAND)+(STAKE(HAND)*1.5)
Inc _BLACKJACKS
Goto ST4RT2
End If
End If
POS=1
HAND_DECIDED=False
While DEALER_COUNT<17
Gosub DEAL_CARD : Inc POS
ADJUST_HAND[3]
DEALER_COUNT=DEALER_COUNT+RANK
' Check for a dealer blackjack
If DEALER_COUNT=21 and POS=2
HAND_DECIDED=True
If PL4YER_COUNT(HAND)=99
BANK=BANK+STAKE(HAND)
End If
Exit
End If
If PL4YER_COUNT(HAND)=99 and POS=2
HAND_DECIDED=True
BANK=BANK+STAKE(HAND)+(STAKE(HAND)*1.5)
Inc _BLACKJACKS
Exit
End If
If DEALER_COUNT>21 and NUM_OF_ACES(3)>0
Dec NUM_OF_ACES(3) : Rem Adjustment made so cancel this ace.
DEALER_COUNT=DEALER_COUNT-10
End If
Wend
If HAND_DECIDED Then Goto ST4RT2
If Not SPLIT
' dealer bust
If DEALER_COUNT>21
BANK=BANK+STAKE(HAND)*2
Goto ST4RT2
End If
' dealer equal
If DEALER_COUNT=PL4YER_COUNT(HAND)
BANK=BANK+STAKE(HAND)
Goto ST4RT2
End If
' dealer wins do nothing
If DEALER_COUNT>PL4YER_COUNT(HAND)
Goto ST4RT2
End If
' if its got this far player wins
BANK=BANK+STAKE(HAND)*2
Goto ST4RT2
Else
If DEALER_COUNT>21
For HAND=1 To 2
If BUST(HAND)=False
BANK=BANK+STAKE(HAND)*2
End If
Next HAND
Goto ST4RT2
End If
For HAND=1 To 2
If DEALER_COUNT<PL4YER_COUNT(HAND) and BUST(HAND)=False
BANK=BANK+STAKE(HAND)*2
End If
If DEALER_COUNT=PL4YER_COUNT(HAND) and BUST(HAND)=False
BANK=BANK+STAKE(HAND)
End If
Next HAND
Goto ST4RT2
End If
'
'
'Display screen 2 and allow selection of staking plan
'
_GET_PLAN:
'Get rid of last key press.
Wait 15
Screen 3
Reserve Zone
Reserve Zone 17
Z=0
For X=22 To 232 Step 70
For Y=20 To 140 Step 40
Inc Z
Set Zone Z,X,Y To X+69,Y+40
Next Y
Next X
Set Zone 17,138,187 To 185,196
M=0
While M=0
PLAN=Mouse Zone
M=Mouse Key
' Change the figure after PLAN> cope with added Staking Plans.
If(PLAN>8 and PLAN<17) Then M=0
If PLAN=0 Then M=0
Wend
If PLAN=17
_MODE=0
_ACC_TOT_HANDS=0
_ACC_TOT_BANK=0
_ACC_TOT_STAKES=0
_SAY_WAIT
Screen Close 0
Return
End If
If PLAN=1 Then _STARTING_STAKE=5
If PLAN=2 Then _STARTING_STAKE=3
If PLAN=3 Then _STARTING_STAKE=3
If PLAN=4 Then _STARTING_STAKE=3
If PLAN=5 Then _STARTING_STAKE=6
If PLAN>5 Then _STARTING_STAKE=5
' Add a line here to set your U/defined _STARTING_STAKE.
Wait 8
Return
'
'
_UPDATE_HI_LO:
Screen 0
Curs Off
If HANDS>0
If BANK=_OLD_BANK
Inc _DRAWS
RESULT$="D"
End If
End If
If BANK>_OLD_BANK Then Inc _WINS : RESULT$="W"
If BANK<_OLD_BANK Then Inc _LOSSES : RESULT$="L"
_OLD_BANK=BANK
If BANK>_HI Then _HI=BANK
If BANK<_LO Then _LO=BANK
Pen 0
Locate 5,1 : Print Using "####";HANDS;
If BANK<0 Then Pen 2
Locate 14,1 : Print Using " ###";BANK;
Pen 0
Locate 23,1 : Print Using " ###";_HI;
Pen 2 : Locate 32,1 : Print Using " ###";_LO; : Pen 0
Locate 5,3 : Print Using " ###";_WINS :
Locate 14,3 : Print Using " ###";_LOSSES;
Locate 23,3 : Print Using " ###";_DRAWS;
Locate 32,3 : Print Using " ###";_BLACKJACKS;
Screen Copy 0,8,0,16,8 To 0,0,0
X=Free
Screen 1
Return
'
' At the end of a session print summary on hidden screen
'
_PRINT_SUM_LINE:
Screen 2 : Locate 2,SESSION+2
Print Using "##";SESSION;
Print Using " ####";HANDS; : _TOT_HANDS=_TOT_HANDS+HANDS
Print Using " ###";_SPLITS; : _TOT_SPLITS=_TOT_SPLITS+_SPLITS
Print Using " ###";_DOUBLES; : _TOT_DOUBLES=_TOT_DOUBLES+_DOUBLES
Print Using " ###";_BLACKJACKS; : _TOT_BLACKJACKS=_TOT_BLACKJACKS+_BLACKJACKS
Print Using " ###";_WINS; : _TOT_WINS=_TOT_WINS+_WINS
Print Using " ###";_LOSSES; : _TOT_LOSSES=_TOT_LOSSES+_LOSSES
Print Using " ###";_DRAWS; : _TOT_DRAWS=_TOT_DRAWS+_DRAWS
Print Using " -###";BANK; : _TOT_BANK=_TOT_BANK+BANK
X=Free
Return
'
' After last session print the totals on hidden screen
_PRINT_SUM_TOTALS:
Screen 2
Locate 1,SESSION+3 : Print "Totals:" : Locate 8,SESSION+3
Print Using "######";_TOT_HANDS; : _ACC_TOT_HANDS=_ACC_TOT_HANDS+_TOT_HANDS
_TOT_HANDS=0
Print Using " #####";_TOT_SPLITS; : _TOT_SPLITS=0
Print Using " #####";_TOT_DOUBLES; : _TOT_DOUBLES=0
Print Using " #####";_TOT_BLACKJACKS; : _TOT_BLACKJACKS=0
Print Using "#####";_TOT_WINS; : _TOT_WINS=0
Print Using " #####";_TOT_LOSSES; : _TOT_LOSSES=0
Print Using " #####";_TOT_DRAWS; : _TOT_DRAWS=0
Print Using " -#####";_TOT_BANK; : _ACC_TOT_BANK=_ACC_TOT_BANK+_TOT_BANK
_TOT_BANK=0
Locate 1,SESSION+5 : Print "Accumulated Total Hands: ";
Print Using "#######";_ACC_TOT_HANDS;
Locate 1,SESSION+6 : Print "Accumulated Profit/Loss: ";
Print Using "-######";_ACC_TOT_BANK;
Locate 1,SESSION+7 : Print "Accumulated Amount Staked: ";
Print Using "########";_ACC_TOT_STAKES;
Locate 1,SESSION+8 : Print "House Edge: ";
Print Using "-###.##";-1*(_ACC_TOT_BANK*100.0)/_ACC_TOT_STAKES
Locate 10,21 : Print "Press Mouse Button for more Tests.";
X=Free
Return
'
' Staking plans
'
_STAKE1:
' Level Stake of 5 units per bet
STAKE(1)=5
Return
_STAKE2:
STAKE(1)=Rnd(24)+1
Return
'
'
'
_STAKE3:
'Starting stake = 3
'After Win Add 3 to limit of 25
'After Loss stake 3
If R$="W" Then STAKE(1)=STAKE(1)+3
If R$="L" Then STAKE(1)=3
If STAKE(1)>25 Then STAKE(1)=25
Return
'
'
'
_STAKE4:
' Starting stake = 3
' After Win subtract 3 (unless the stake is 3)
' After loss add 3 to the limit of 25
If R$="W" Then STAKE(1)=3
If R$="L" Then STAKE(1)=STAKE(1)+3
If STAKE(1)>25 Then STAKE(1)=25
If STAKE(1)<3 Then STAKE(1)=3
Return
'
'
'
_STAKE5:
'If BANK<0 Then STAKE(1)=Min((Abs(BANK)+6)/4,25)
'If BANK>=0 Then STAKE(1)=6
If BANK<0 Then STAKE(1)=Min((Abs(BANK)+6)/4,25) Else STAKE(1)=6
If STAKE(1)<6 Then STAKE(1)=6
Return
'
'
'
_STAKE6:
'If Bank>0 then enlarge the bet
'If Bank+<0 the bet 6
If BANK>0 Then STAKE(1)=Min((BANK+6)/4,25) Else STAKE(1)=6
If STAKE(1)<6 Then STAKE(1)=6
Return
'
'
'
_STAKE7:
' If loose - Double until 25
If R$="L" Then STAKE(1)=Min(25,STAKE(1)*2)
If R$="W" Then STAKE(1)=5
Return
'
'
'
_STAKE8:
' If won - Double until 25
If R$="W" Then STAKE(1)=Min(25,STAKE(1)*2)
If R$="L" Then STAKE(1)=5
Return
'
' Put user defined Staking plans here.(_STAKE9 to _STAKE16)
'
'
Procedure _GRAPH_PAPER
Shared SESS$,SESSION,STAKE$,PLAN,X#
Screen Open 1,960,164,8,Lowres
Double Buffer : Curs Off : Flash Off : Get Sprite Palette
Autoback 0
Screen 1
Screen Hide 1
Cls 1,0,0 To 959,160
Screen Display 1,120,85,,
Ink 7 : Draw 0,82 To 959,82 : Ink 5 : Draw 0,107 To 959,107
Draw 0,32 To 959,32 : Draw 0,57 To 957,57 : Draw 0,132 To 959,132
For P=0 To 959 Step 32 : Draw P,0 To P,160 : Next P
Locate 27,1 : Print SESS$;SESSION;
If PLAN<>0 Then Locate 27,3 : Print STAKE$;PLAN
X=Free
Screen Copy 1,48+X#,0,333+X#,156 To 0,18,40
Autoback 2
End Proc
Procedure _GET_TOP_BOTTOM
Shared LINE$(),BUTTON$(),Q,_LOWEST,_HIGHEST
LINE$(0)="How many Units can you afford"
LINE$(1)="to Loose per Session?"
BUTTON$(0)="50"
BUTTON$(1)="100"
BUTTON$(2)="150"
BUTTON$(3)="200"
BUTTON$(4)="300"
ALERT[34,8,1,2,5,2]
Bell
If Q<5 Then _LOWEST=Q*-50 Else _LOWEST=-300
Wait 15
LINE$(0)="How many Units do you want"
LINE$(1)="to Win per Session?"
ALERT[34,8,1,2,5,2]
Bell : Wait 8
If Q<5 Then _HIGHEST=Q*50 Else _HIGHEST=300
End Proc
Procedure _GET_NUM_OF_SESSIONS
Shared Q,LINE$(),BUTTON$(),NUM_OF_SESSIONS
LINE$(0)="How many Test Sessions"
LINE$(1)="do you want me to Play?"
BUTTON$(0)="1"
BUTTON$(1)="5"
BUTTON$(2)="10"
ALERT[34,8,1,2,3,2]
Bell
If Q=1 Then NUM_OF_SESSIONS=Q Else NUM_OF_SESSIONS=(Q-1)*5
Wait 15
End Proc
Procedure _GET_NUM_HANDS
Shared LINE$(),BUTTON$(),Q,NUM_OF_HANDS
LINE$(0)="How many hands do you want"
LINE$(1)="me to play in each session?"
BUTTON$(0)="250"
BUTTON$(1)="500"
BUTTON$(2)="750"
BUTTON$(3)="1000"
ALERT[34,8,1,2,4,2]
Bell
NUM_OF_HANDS=Q*250
X=Free
End Proc
Procedure SPLIT_HELP
Shared SPLIT_ADVICE,_TWO_ACES
' 101 to 200 SPLIT_HELP
_OFFSET=99
PL4Y=PL4YER_COUNT(HAND)/2 : DEAL=DEALER_COUNT-1
If _TWO_ACES Then PL4Y=11
If PL4Y>6
PL4Y=PL4Y-(PL4Y-6)*2
Else
If PL4Y<>6
PL4Y=PL4Y+(6-PL4Y)*2
End If
End If
SEL=Peek(Start(8)+_OFFSET+(PL4Y-1)*10+DEAL)
If SEL=1
LIGHT[3]
SPLIT_ADVICE=True
End If
End Proc
Procedure SOFT_HIT_HELP
' 1 to 40 Soft_HIT
_OFFSET=-1
DEAL=DEALER_COUNT-1
If PL4YER_COUNT(HAND)>16
PL4Y=21-PL4YER_COUNT(HAND)
If PL4Y<1 : Rem this stops 21 overflowing the array
PL4Y=1 : Rem but gives the same advice
End If
SEL=Peek(Start(8)+_OFFSET+(PL4Y-1)*10+DEAL)
If SEL=1
LIGHT[2]
Else
LIGHT[1]
End If
Else
LIGHT[2]
End If
End Proc
Procedure HARD_D0UBLE_HELP
Shared D0UBLE
_OFFSET=269
PL4Y=12-PL4YER_COUNT(HAND) : DEAL=DEALER_COUNT-1
SEL=Peek(Start(8)+_OFFSET+(PL4Y-1)*10+DEAL)
If SEL=1
LIGHT[4]
D0UBLE=True
End If
End Proc
Procedure HARD_HIT_HELP
Shared HARD_DBL(),SOFT_DBL(),HARD_HIT(),SOFT_HIT(),SPLIT(),D0UBLE
' 41 to 100 HARD_HIT
_OFFSET=39
If PL4YER_COUNT(HAND)<12
LIGHT[2]
Goto _EXIT
End If
If PL4YER_COUNT(HAND)<18
PL4Y=18-PL4YER_COUNT(HAND) : DEAL=DEALER_COUNT-1
SEL=Peek(Start(8)+_OFFSET+(PL4Y-1)*10+DEAL)
If SEL=1
LIGHT[2]
Else
LIGHT[1]
End If
Else
LIGHT[1]
End If
_EXIT:
End Proc
Procedure _GRAPH
Shared _GRAPHY,X#,NUM_OF_HANDS
Screen Offset 1,HANDS,0
If NUM_OF_HANDS>500
X#=X#+0.5
Else
X#=X#+1.0
End If
_GRAPHX=X#+319
_GRAPHY=82-_WINS+_LOSSES
Bob 2,_GRAPHX,_GRAPHY-2,1
Plot _GRAPHX,_GRAPHY,2
_GRAPHY=82-BANK/4
Bob 1,_GRAPHX,_GRAPHY-2,2
Plot _GRAPHX,_GRAPHY,6
Ink 2
Sam Play 1,1,35000
Screen Copy 1,48+X#,0,333+X#,156 To 0,18,40
X=Free
End Proc
Procedure ADJUST_HAND[N]
Shared RANK
If RANK>10 Then RANK=10
If RANK=1 Then RANK=11
If RANK=11
Inc NUM_OF_ACES(N)
SOFT(N)=True
End If
End Proc
' Thanks to Sprite editor for this Proc.
Procedure ALERT[W,H,C1,C2,NB,NL]
Shared Q,LINE$(),BUTTON$()
Reserve Zone
Reserve Zone 5
W=W*8
H=H*8
X=160-W/2
Y=50-H/2
Get Block 1,X,Y,W+16,H+16
Ink 0
Bar X+5,Y+5 To X+W+5,Y+H+5
Ink C1
Bar X,Y To X+W,Y+H
Ink C2
Box X+1,Y+1 To X+W-1,Y+H-1
S=W/8/(NB+1)+1
Paper C1
Pen C2
Curs Off
_S=Screen
Screen Copy _S,8,0,16,8 To _S,0,0 : Screen Swap
Screen Copy _S,8,0,16,8 To _S,0,0 : Screen Swap
Screen Copy _S,8,0,16,8 To _S,0,0 : Screen Swap
Screen Copy _S,8,0,16,8 To _S,0,0 : Screen Swap
Wait Vbl
A=0 : While A<NB
Locate X Text(X)+S/2+S*A,Y Text(Y+H)-2
Print Border$(Zone$(BUTTON$(A),1+A),2);
Inc A : Wend
A=0 : While A<NL
Locate 0,Y Text(Y)+1+A
Centre LINE$(A)
Inc A
Wend
Q=0
While Q=0
While Mouse Key=0 : Wend
Z=Mouse Zone
If Z<1 or Z>1+NB
Bell
Else
Q=Z
End If
Wend
Put Block 1,X,Y
End Proc
Procedure CLAIM_STAKE
Shared DUBBLED()
TEMP_FL=DUBBLED(HAND)
If HAND=2 Then HAND=3
Channel 1 To Bob HAND
Channel 2 To Bob HAND+1
AM$="Move 0,40,25"
If BLUE_CHIPS>0
Amal 1,AM$
End If
If RED_CHIPS>0
Amal 2,AM$
End If
If TEMP_FL and BLUE_CHIPS>0
Channel 3 To Bob HAND+4 : Amal 3,AM$
End If
If TEMP_FL and RED_CHIPS>0
Channel 4 To Bob HAND+5 : Amal 4,AM$
End If
If HAND=3 Then HAND=2
Amal On
While Chanmv(1) or Chanmv(2) or Chanmv(3) or Chanmv(4)
Wend
Wait 35
End Proc
Procedure _DRAW_CHARTS
Z=0
For X=1 To 5
Read TLX,TLY,NUM_OF_ROWS
For ROW=0 To NUM_OF_ROWS-1
For _COLUMN=0 To 9
Z=Z+1
A=TLX+_COLUMN*8 : B=TLY+ROW*10
If Peek(Start(8)+Z-1)=1
Ink 3
Else
Ink 1
End If
Bar A+1,B+1 To A+7,B+9
Ink 2
Set Zone Z,A,B To A+8,B+10
Next _COLUMN
Next ROW
Next X
Data 20,30,4,20,99,6,120,30,10,220,30,7,221,129,3
End Proc
Procedure _EDIT_STRATEGY
Change Mouse 3
Auto View Off
Screen Open 2,320,256,4,Lowres
Load Iff "trainer:strat_boxes.iff"
Reserve Zone
Reserve Zone 300
Flash Off : Curs Off
Palette 0,$380,$FFF,$F00
_DRAW_CHARTS
Auto View On
Screen To Front 2
_DONE=False
Do
_DRAW_CHARTS
Change Mouse 2
M=0
While M=0
M=Mouse Key
If M=2 Then Goto _DONE
Wend
Change Mouse 3
OLD=Peek(Start(8)+Mouse Zone-1)
If OLD=1 Then Poke(Start(8)+Mouse Zone-1),0
If OLD=0 Then Poke(Start(8)+Mouse Zone-1),1
Loop
_DONE:
Change Mouse 1
End Proc
Procedure GAME_LOST
Music 1
Sprite Off 1 : Bob Off
Screen Open 2,320,200,16,Lowres
Load Iff "trainer:BJ_game_end"
Screen Display 2,,-142,,
For Y=-142 To 64
Screen Display 2,,Y,,
Wait Vbl
Next
Wait 20
Music Off
Reserve Zone
Reserve Zone(2)
Set Zone 1,105,25 To 200,84
Set Zone 2,105,111 To 200,170
NEWZONE=0 : _DONE=False
Repeat
If Mouse Zone=1 and Mouse Key<>0
For Y=64 To -142 Step -4
Screen Display 2,,Y,,
Wait Vbl
Next Y
Screen Close 2
_DONE=True
End If
If Mouse Zone=2 and Mouse Key<>0 Then End
Until _DONE
End Proc
Procedure LIGHT[ADVICE]
Shared AN$,NEWZONE,_MODE
If _MODE=0
Sprite 1,185,137+ADVICE*16,65
Channel 9 To Sprite 1
Amal 9,AN$
Amal On 9
Else
NEWZONE=ADVICE
End If
End Proc
Procedure _LOAD_ARRAY
Shared SPEED_ARR$()
For S=0 To 2
Read SPEED_ARR$(S)
Next S
Data "Fast","Med.","Slow"
End Proc
Procedure _LOAD_STRAT
F$="" : While F$=""
F$=Fsel$("*.STR",""," Load A STRATEGY FILE ")
If F$<>""
A$=Upper$(F$)
If Right$(A$,4)<>".STR"
F$=F$+".STR"
End If
Bload F$,8
Else
F$=" "
End If
Wend
End Proc
Procedure MAKE_CHIP_PILE[BET]
RED_CHIPS=BET mod 5 : BLUE_CHIPS=Int(BET/5)
If BET=0 Then RED_CHIPS=0
End Proc
Procedure MAKE_PACK
Shared CARD_PACK()
CARD=1
For P4CK=1 To 4
For RANK=1 To 13
For SUIT=0 To 3
CARD_PACK(CARD)=SUIT*100+RANK
Inc CARD
Next SUIT
Next RANK
Next P4CK
End Proc
Procedure M0USE_CHIP_MOVE
Rem get chips to follow pointer
If RED_CHIPS>0
Bob B0B+1,X Screen(X Mouse),Y Screen(Y Mouse)-BLUE_CHIPS*2-1,RED_CHIPS
Else
Bob Off B0B+1
End If
If BLUE_CHIPS>0
Bob B0B,X Screen(X Mouse),Y Screen(Y Mouse),BLUE_CHIPS+4
Else
Bob Off B0B
End If
End Proc
Procedure _CLEAR_BOX
Bob Update
Put Block 1
Screen Swap : Wait Vbl
Put Block 1
Screen Swap : Wait Vbl
End Proc
Procedure _NOTICE[S$]
W=Len(S$)/2*16+24
H=16
X=148-(Len(S$)/2)*8
Y=202
Get Block 1,X,Y,W+24,H+10
Ink 0
Bar X+5,Y+5 To X+W+8,Y+H+5
Ink 1
Bar X,Y To X+W+4,Y+H
Ink 0
Box X+1,Y+1 To X+W+2,Y+H-1
Ink 2
Curs Off
Screen Copy S,8,0,16,8 To S,0,0 : Screen Swap
Screen Copy S,8,0,16,8 To S,0,0 : Screen Swap
Locate 19-(Len(S$)/2),26 : Print S$;
Bell : Wait 100
S=Screen
End Proc
Procedure PAY_EVENS
Shared DUBBLED(),_MODE
BANK=BANK+STAKE(HAND)*2
TEMP_FL=DUBBLED(HAND)
If HAND=2
HAND=3
End If
B0B=B0B+HAND
Channel 1 To Bob B0B
Channel 2 To Bob B0B+1
If BLUE_CHIPS>0
Bob B0B,0,0,I Bob(1)
AM$=AM$+"Move"+Str$(X Bob(HAND))+"-20,"+Str$(Y Bob(HAND))+"-19,60"
Amal 1,AM$ : Amal On 1
End If
If RED_CHIPS>0
Bob B0B+1,0,0,I Bob(2)
AM$="Move"+Str$(X Bob(HAND+1))+"-20,"+Str$(Y Bob(HAND+1))+"-19,60"
Amal 2,AM$ : Amal On 2
End If
If TEMP_FL and BLUE_CHIPS>0
Bob B0B+2,0,0,I Bob(HAND+4)
AM$="Move"+Str$(X Bob(HAND+4))+"-20,"+Str$(Y Bob(HAND+4))+"-19,60"
Channel 3 To Bob B0B+2 : Amal 3,AM$ : Amal On 3
End If
If TEMP_FL and RED_CHIPS>0
Bob B0B+3,0,0,I Bob(HAND+5)
AM$="Move"+Str$(X Bob(HAND+5))+"-20,"+Str$(Y Bob(HAND+5))+"-19,60"
Channel 4 To Bob B0B+3 : Amal 4,AM$ : Amal On 4
End If
If HAND=3
HAND=2
End If
Bob 42,-20,-24,66
Channel 5 To Bob 42 : Amal 5,AM$
Amal On 5
Repeat : Until Chanmv(2)=0 and Chanmv(1)=0
Amal Off
AM$="Move -40,-195,30"
Amal 5,AM$ : Amal On
While Chanmv(5) : Wend : Amal Off
End Proc
Procedure PAY_SIX_TO_4
Shared BET,_MODE
BANK=BANK+STAKE(HAND)+(STAKE(HAND)*1.5)
Inc B0B
Channel 1 To Bob B0B
Channel 2 To Bob B0B+1
Channel 3 To Bob B0B+2
Channel 4 To Bob B0B+3
If BLUE_CHIPS>0
BLUE_X=X Bob(1) : BLUE_Y=Y Bob(1)
Bob B0B,0,0,I Bob(1)
AM$="Move"+Str$(BLUE_X)+"-20,"+Str$(BLUE_Y)+",100"
Amal 1,AM$
End If
If RED_CHIPS>0
RED_X=X Bob(2) : RED_Y=Y Bob(2)
Bob B0B+1,0,0,I Bob(2)
AM$="Move"+Str$(RED_X)+"-20,"+Str$(RED_Y)+",100"
Amal 2,AM$
End If
BET2=BET/2
If STAKE(HAND) mod 2=1
If OWES_50P
Inc BET2
Inc BANK
OWES_50P=False
Else
OWES_50P=True
End If
End If
If _MODE=0
If BET2>0
MAKE_CHIP_PILE[BET2]
If BLUE_CHIPS>0
Bob B0B+2,0,0,4+BLUE_CHIPS
AM$="Move"+Str$(BLUE_X)+"-40,"+Str$(BLUE_Y)+",100"
Amal 3,AM$
End If
If RED_CHIPS>0
Bob B0B+3,0,0,RED_CHIPS
AM$="Move"+Str$(Max(BLUE_X,RED_X))+"-40,"
AM$=AM$+Str$(Max(BLUE_Y,RED_Y))+"-5,100"
Amal 4,AM$
End If
End If
Bob 42,-20,-24,66
Channel 5 To Bob 42
Amal 5,AM$
Amal On
While Chanmv(1) or Chanmv(2) or Chanmv(3) or Chanmv(4)
Wend
Wait 5
AM$="Move -40,-190,30"
Amal 5,AM$ : Amal On
While Chanmv(5) : Wend
End If
End Proc
Procedure _PROCESS[G$]
Menu Off
Screen Open 4,640,250,4,Hires
View
Curs Off
Restore G$
A$=""
LINE=0
While A$<>"**"
Read A$
Locate 0,LINE
If A$="*"
Print " "
Print " Left Mouse Button to continue."
Wait 20
While Mouse Key<>1 : Wend
Cls
LINE=0
Else
Print A$
Inc LINE
X=Free
End If
Wend
Screen Close 4
Menu On
RULES:
Data " Rules of the House."
Data " ==================="
Data " "
Data "1. Four decks of cards are used, and after each shuffle approximately"
Data " 12 cards are 'burned' from the bottom of the pack."
Data " Each card has its face value. Court cards count as ten. Aces count"
Data " as either 1 or 11, whichever is to the hand's advantage."
Data " "
Data "2. The player must bet before any cards are dealt."
Data " "
Data "3. All cards are dealt face up. The dealer will deal two cards to the"
Data " player and one to himself. Only after the player has completed his"
Data " hand will the dealer deal more cards to himself."
Data " "
Data "4. Any hand with a count of over 21 is 'bust'."
Data " "
Data "5. Dealer stands on a hand of 17 or more, whether hard or soft."
Data " "
Data "6. Dealer must hit a hand of 16 or less."
Data " "
Data "7. Player may stand at any time."
Data " "
Data "8. Player may double his bet after the second card. In this case"
Data " only one more card will be dealt to that hand."
Data "*"
Data " "
Data "9. Player may split his hand if his first two cards are of equal value."
Data " Only one split is permitted per hand. The second hand will carry the"
Data " same stake as the initial hand."
Data " "
Data "10. Your stake is returned in the case of a draw or'Stand Off'."
Data " "
Data "11. A player winning with a Blackjack (an Ace plus ten or a Court card)"
Data " will be paid one and a half times his stake, except in split hands,"
Data " when the hand will be treated as a normal count of 21."
Data " (As there are no 50p chips, in the case of Blackjack on a bet of an"
Data " odd amount, the extra 50p will be added to the next similar payout"
Data " thus rounding it up.)"
Data " "
Data "12. In the event of the dealer getting Blackjack the dealer wins unless the"
Data " player has Blackjack, in which case it will count as a draw."
Data "*"
Data "**"
_INSTRUCT:
Data " INSTRUCTIONS."
Data " ============="
Data " The Game."
Data " ---------"
Data " The player must place a bet before any cards are dealt. To do this"
Data " use the mouse to pick up chips from either or both of the two boxes"
Data " marked '�1' and '�5'. The left mouse button will pick up chips"
Data " (increase the bet); the right button will drop chips (decrease the"
Data " bet)."
Data " "
Data " To place the bet simply move the chips into the betting box with"
Data " the mouse and press the left button."
Data " "
Data " The dealer will deal two cards to the player and one to himself."
Data " It is now up the player make his choice of 'Stand', 'Hit', 'Double', or"
Data " 'Split' where allowable."
Data " "
Data " The object of the game, for both player and dealer, is to get as high"
Data " a score as possible without going over 21."
Data " "
Data " Once the player has either bust (gone over 21) or stood (stopped"
Data " drawing cards) on all his hands the dealer will deal his hand"
Data " according to the rules."
Data " "
Data " After each hand a fresh bet must be placed before the game can"
Data " continue. "
Data "*"
Data " "
Data " OPTIONS."
Data " ========"
Data " "
Data " If 'Play with Help' has been selected from the Options menu, one"
Data " of the four red lights beside the play buttons will flash. This is"
Data " the advised play for the player's card count, having taken the dealer's"
Data " card into consideration."
Data " "
Data " If 'Play without Help' has been selected, advice is still available"
Data " from the 'Help' key."
Data " "
Data " The advice is based on the strategy file which is currently loaded."
Data " To alter the strategy select 'Edit Strategy' from the 'Options' menu"
Data " To save a strategy to disc select 'Save Strategy'. Each strategy file"
Data " MUST be given '.str' as an extension to the file name. 'Load Strategy'"
Data " will allow the user to select a previously saved Strategy file."
Data " "
Data " The 'Select Speed' option allows the player to vary the speed at which"
Data " the cards are dealt."
Data " "
Data "*"
Data " "
Data " 'Test Current Strategy' will enable a Strategy to be tested by"
Data " instructing the computer to play up to 10,000 hands using the Strategy"
Data " currently loaded."
Data " "
Data " While playing a player may save a game to disc or load a "
Data " previously saved game using the LOAD and SAVE buttons."
Data " The MENU button will return the player to the Menu Screen."
Data " These three buttons only function between hands."
Data " "
Data " (See Docs for further details.)"
Data "*"
Data "**"
STRATEGY:
Data " Strategy"
Data " ========"
Data ""
Data " "
Data " At first glance the dealer has an enormous advantage in"
Data " Blackjack, because he does not have to draw cards to his hand"
Data " until all the players have either Stood or Bust. So that if"
Data " both the player and the dealer bust, the dealer wins on what"
Data " is, in effect, a draw."
Data " "
Data " To counter-balance this the player is allowed to Stand at"
Data " any time, whereas the dealer MUST Hit a hand of sixteen or"
Data " less. In addition, the player is given the opportunity to"
Data " increase his stake when the cards are in his favour, and"
Data " the player gets paid at odds of six to four on a Blackjack."
Data " "
Data " It follows that a knowledge of what are 'good' and what"
Data " are 'bad' hands will help your money go that much further"
Data " and, who knows, one day you may actually win something."
Data "*"
Data " "
Data " There follows a table of what this program will train you"
Data " to do using the default Strategy. "
Data " "
Data " If you wish to alter the strategy simply select 'Edit Strategy'"
Data " from the Options Menu and edit the chart to your liking. "
Data " "
Data " (Note: The term 'Hard hand' refers to hand which does not"
Data " have any aces in it or a Soft hand which has gone over 21.)"
Data "*"
Data " "
Data " PLAYER PLAY"
Data " ====== ===="
Data " "
Data " Hitting on Hard Hands"
Data " "
Data " Less than 12 Always Hit. Cannot Bust."
Data " 12 Hit when dealer has 2 or 3."
Data " 12 - 16 Hit when dealer has more than 6."
Data " "
Data " Hitting Soft Hands"
Data " "
Data " 18 (Ace+7) Hit when dealer has 9 or 10."
Data " Less than 18 Always Hit."
Data "*"
Data " "
Data " PLAYER PLAY"
Data " ====== ===="
Data " "
Data " Doubling Hard Hands"
Data " "
Data " 11 Always Double."
Data " 10 When dealer has 2-9"
Data " 9 When dealer has 2-6"
Data " "
Data " Doubling Soft Hands"
Data " "
Data " 13 to 16 When dealer has 4-6"
Data " 17 When dealer has 2-6"
Data " 18 When dealer has 3-6"
Data "*"
Data " "
Data " PLAYER PLAY"
Data " ====== ===="
Data ""
Data " Splitting"
Data " "
Data " Aces and 8s Always Split."
Data " 10s and 5s Never Split. "
Data " 9s Not when dealer has 7,10 or Ace."
Data " 7s When dealer has 2-8."
Data " 6s When dealer has 2-7."
Data " 4s When dealer has 5."
Data " 3s and 2s When dealer has 2-7."
Data "*"
Data "**"
DETAILS:
Data " Blackjack Trainer is written by Peter Cartwright using the"
Data " AMOS Compiler."
Data " "
Data " Many thanks to Kevin Hall for the samples, moral support and"
Data " suggestions."
Data " "
Data " Address any comments, brickbats or donations to:"
Data " "
Data " Peter Cartwright,"
Data " 68a Dornton Road,"
Data " London. SW12 9NE."
Data " 081 673 0971."
Data "*"
Data "**"
STAKING:
Data " "
Data " STAKING PLANS."
Data " "
Data " When 'Test Current Strategy' is selected from the Options"
Data " Menu you will be offered a choice of eight staking plans to"
Data " use in your test runs. Please refer to the Docs file for details"
Data " of what each staking plan will do."
Data " "
Data " There is room for eight more staking plans in the program. so if"
Data " you have any staking systems which you would like to test over"
Data " long runs I will gladly customise the program for you for �2"
Data " plus �3 per staking plan. Please read the Docs file for details."
Data "*"
Data "**"
End Proc
Procedure _SAVE_STRAT
F$="" : While F$=""
F$=Fsel$("*.STR","","Save a Strategy File","MUST have '.STR' as extension")
If F$<>""
A$=Upper$(F$)
If Right$(A$,4)=".STR"
Bsave F$,Start(8) To Start(8)+Length(8)
Else
F$=""
End If
Else
F$=" "
End If
Wend
End Proc
Procedure _SAVE_GAME
Shared CARD_PACK(),T0P_CARD,BOTTOM_CARD
_LOOP:
F$=Fsel$("*.GAM","","Save a .GAM file","MUST have .GAM extention")
If F$="" Then Goto _EXIT1
If Upper$(Right$(F$,4))<>".GAM" Then Goto _LOOP
S$="Saving ..." : _NOTICE[S$]
Open Out 1,F$
Print #1,BANK
Print #1,T0P_CARD
Print #1,BOTTOM_CARD
For X=1 To 208 : Print #1,CARD_PACK(X) : Next X
Close 1
_CLEAR_BOX
_EXIT1:
End Proc
Procedure _LOAD_GAME
Shared CARD_PACK(),T0P_CARD,BOTTOM_CARD
F$=Fsel$("*.GAM","","Load A GAME FILE ")
If F$="" Then Goto _EXIT2
S$="Loading... "
_NOTICE[S$]
Open In 1,F$
Input #1,BANK
Input #1,T0P_CARD
Input #1,BOTTOM_CARD
For X=1 To 208 : Input #1,CARD_PACK(X) : Next X
Close 1
_CLEAR_BOX
_UPDATE_BANK
_EXIT2:
End Proc
Procedure SET_MAIN_ZONES
Reserve Zone
Reserve Zone 10
For I=1 To 6
Read TLX,TLY,BRX,BRY
Set Zone I+4,TLX,TLY To BRX,BRY
Next I
For I=0 To 3
Set Zone I+1,3,106+16*I To 53,122+16*I
Wait Vbl
Next I
Data 130,174,162,194
Data 161,174,194,194
Data 142,104,175,158
Data 35,208,81,219
Data 245,208,291,219
Data 135,224,185,240
End Proc
Procedure TAKE_MONEY
Shared DUBBLED()
TEMP_FL=DUBBLED(HAND)
If HAND=2 Then HAND=3
Channel 1 To Bob HAND
Channel 2 To Bob HAND+1
AM$="Move -70,-160,45"
If BLUE_CHIPS>0
Amal 1,AM$
GRABBER_POSX=X Bob(HAND)-20 : GRABBER_POSY=Y Bob(HAND)-24
End If
If RED_CHIPS>0
Amal 2,AM$
GRABBER_POSX=X Bob(HAND+1)-20 : GRABBER_POSY=Y Bob(HAND+1)-24
End If
' take care of doubles
If TEMP_FL and BLUE_CHIPS>0
Channel 3 To Bob HAND+4 : Amal 3,AM$
End If
If TEMP_FL and RED_CHIPS>0
Channel 4 To Bob HAND+5 : Amal 4,AM$
End If
Bob 42,GRABBER_POSX,GRABBER_POSY,66
Wait 20
Channel 5 To Bob 42
Amal 5,AM$
Amal On
If HAND=3 Then HAND=2
Wait 50
End Proc
Procedure _UPDATE_BANK
Text 68,188,"�"+Str$(BANK)+" "
End Proc
Procedure _SET_UP_1ST_SCREENS
Auto View Off
Screen Open 0,320,256,16,Lowres
Flash Off : Curs Off
Load "Trainer:table.pic.pac",9
Unpack 9 To 0 : Erase 9
Screen Hide 0
Double Buffer
Palette ,,,$191
Limit Mouse 128,42 To 444,298
Screen Open 1,320,256,16,Lowres
Auto View On
Load "Trainer:bj_menuscreen.pac",10
Flash Off
Unpack 10 To 1 : Erase 10
Screen Display 0,128,298,,
End Proc
Procedure _SAY_WAIT
S$="Please Wait..."
Ink 0
Bar 100,146 To 230,166
Ink 1
Box 102,148 To 228,164
Paper 0 : Pen 1
Locate 14,19 : Print S$;
X=Free
End Proc
Procedure _SCROLL_UP
Screen Show 0
SY1=42 : SY2=298
For Z=1 To 64 : Wait Vbl : Screen Display 1,128,SY1,, : Screen Display 0,128,SY2,, : SY1=SY1-4 : SY2=SY2-4 : Next Z
Screen Hide 1
End Proc
Procedure _SCROLL_DOWN
Screen Show 1
SY1=-214 : SY2=42
For Z=1 To 64 : Wait Vbl : Screen Display 1,128,SY1,, : Screen Display 0,128,SY2,, : SY1=SY1+4 : SY2=SY2+4 : Next Z
Screen Hide 0
End Proc